package com.wuerer.bath.controller;

import com.wuerer.bath.Service.UserService;
import com.wuerer.bath.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ：Leo
 * @date ：Created in 2022/10/16 10:58
 * @description：
 */
@Controller
public class LoginController {
    @Autowired
    UserService userService;
    @RequestMapping("/login")
    @ResponseBody
    public User login(@Param("name")String name,@Param("password")String password){
        if (StringUtils.hasLength(name)&&StringUtils.hasLength(password)){
        User user = userService.getUserByName(name);
        if (user!=null&&user.getPassword().equals(password)) return user;
        }
        return null;
    }
}
